<template>
  <div class="select-button-group">
    <el-button
      v-for="(item, index) in list"
      :key="index"
      :type="item.type"
      @click="change(item, index)"
      >{{ item.name }}</el-button
    >
  </div>
</template>

<script>
export default {
  name: 'Checkbox',
  props: {
    defaultType: {
      type: String,
      default() {
        return 'primary'
      },
    },
    list: {
      type: Array,
      default() {
        return []
      },
    },
  },
  data() {
    return {}
  },
  methods: {
    change(item, index) {
      this.list.map((item, i) => {
        if (i === index) {
          item.type = this.defaultType
        } else {
          item.type = ''
        }
      })
      this.$emit('change', item.value)
    },
  },
}
</script>

<style scoped>
</style>
